package ace.cmp.security.test.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;
import org.springframework.security.test.context.support.TestExecutionEvent;
import org.springframework.security.test.context.support.WithSecurityContext;

/**
 * .
 * @author Caspar
 *
 */
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Documented
@WithSecurityContext(
    factory = WithMockBearerTokenAuthenticationSecurityContextFactory.class
)
public @interface WithMockBearerTokenAuthentication {

  /**
   *  attributes屬性，json格式.
   */
  String attributesJson() default "";

  /**
   * authorities属性.
   */
  String[] authorities() default {};

  /**
   * token值.
   */
  String token() default "";

  /**
   * token发布时间.0默认赋值当前时间,单位毫秒.
   */
  long issuedAtTimestampInMilli() default 0;

  /**
   * token过期时间.0默认赋值当前时间 + expiresAtPlusInSeconds,单位毫秒.
   */
  long expiresAtTimestampInMilli() default 0;

  /**
   * token过期时间增加的过期时间,单位毫秒.
   */
  long expiresAtPlusInMilli() default 600000;
  /**
   * scopes屬性.
   */
  String[] scopes() default {};

  @AliasFor(
      annotation = WithSecurityContext.class
  )
  TestExecutionEvent setupBefore() default TestExecutionEvent.TEST_METHOD;
}
